#include "CenteralWidget.h"
#include "FileEncodeOper.h"
#include "TimeOperator.h"
#include "WebEngineWidget.h"

#include <QLabel>
#include <QVBoxLayout>
#include <QTabWidget>
#include <QCalendarWidget>
#include <QScrollArea>



class CentralWidget::Impl
{
public:
    Impl();
    QTabWidget *pTabWdg = nullptr;
    QWidget *waitDevelopWidget();
    QWidget *scrollWidget(QWidget *wdg);
};

CentralWidget::Impl::Impl()
{
    pTabWdg = new QTabWidget;
    pTabWdg->setTabsClosable(false);
    pTabWdg->setTabShape(QTabWidget::Triangular);
    pTabWdg->setTabPosition(QTabWidget::East);

    pTabWdg->addTab(scrollWidget(new TimeOperWidget(pTabWdg)), "TimeOper");
    pTabWdg->addTab(scrollWidget(new FileEnCodeWidget(pTabWdg)), "FileOper");
    pTabWdg->addTab(scrollWidget(new WebEngineWidget(pTabWdg)), "ChatGPT");
    pTabWdg->addTab(waitDevelopWidget(), "Dragon&RabbitMq");
    pTabWdg->addTab(waitDevelopWidget(), "MatLab");
    pTabWdg->addTab(waitDevelopWidget(), "OpenGL");
    pTabWdg->addTab(waitDevelopWidget(), "PythonService");
    pTabWdg->addTab(waitDevelopWidget(), "WeChatProj");
}

QWidget *CentralWidget::Impl::waitDevelopWidget()
{
    QWidget *wdg = new QWidget;
    QLabel *lab = new QLabel("Wait for develop!");
    QVBoxLayout *vLayout = new QVBoxLayout;
    vLayout->addWidget(lab);
    vLayout->addStretch();
    wdg->setLayout(vLayout);
    return wdg;
}

QWidget *CentralWidget::Impl::scrollWidget(QWidget *wdg)
{
    QScrollArea *scArea = new QScrollArea();
    QVBoxLayout *areaVLay = new QVBoxLayout(scArea);
    areaVLay->addWidget(wdg);
    areaVLay->addStretch();
    return scArea;
}

CentralWidget::CentralWidget(QWidget *parent): QWidget(parent),
    _pImpl(new Impl())
{
    initWidget();

}

CentralWidget::~CentralWidget() {}



void CentralWidget::initWidget()
{


    QVBoxLayout *vLeftLayout = new QVBoxLayout;
    QLabel *lab = new QLabel("Today task", this);
    QCalendarWidget *pCalender = new QCalendarWidget;
    pCalender->setSelectedDate(QDate::currentDate());
    vLeftLayout->addWidget(lab, 5);
    vLeftLayout->addWidget(pCalender, 5);

    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addLayout(vLeftLayout, 2);
    hLayout->addWidget(_pImpl->pTabWdg, 5);
    setLayout(hLayout);
}





